<?php
/**
 * 才俊佳丽视频查看与下载
 */

require_once dirname(dirname(__FILE__)) . '/include/common.inc.php';
require_once INCLUDE_ROOT_PATH . 'file_server.class.php';

$cust_id = isset($_REQUEST['cust_id']) ? $_REQUEST['cust_id'] : '';	//资源编号
$act = isset($_REQUEST['act']) ? $_REQUEST['act'] : '';	//操作，view在线查看，download下载
$filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : '';	//要查看或下载的文件名
$token = isset($_REQUEST['token']) ? $_REQUEST['token'] : '';	//token验证

$width = isset($_REQUEST['width']) ? $_REQUEST['width'] : 1024;	//将图片缩放的最大宽度
$height = isset($_REQUEST['height']) ? $_REQUEST['height'] : 1024;//将图片缩放的最大高度

if (empty($cust_id) || !is_numeric($cust_id) || $cust_id <= 0 || $token != md5($cust_id . 'cjjlvideo' . $act . $filename))
{
    $result = '';
}
else
{
    $date_y = substr($filename,0,4);
    $date_m = substr($filename,4,2);
    $date_d = substr($filename,6,2);
    $file_dir = CJJL_VIDEO_ROOT_PATH . $date_y. '/'. $date_m. '/'. $date_d. '/' . $cust_id.'/';
    $filepath = $file_dir . $filename;
    $File_server = new File_server();
    switch ($act)
    {
        case 'view':
            $result = $File_server->view($filepath);
            break;

        case 'download':
            $result = $File_server->download($filepath);
            break;

        default:
            $result = false;
            break;
    }
}
exit;
?>